# encoding: utf-8
"""
@author: 夏洛
@QQ: 1972386194
@file: mains.py
"""

from flask import Flask,render_template,jsonify

# 实例化框架
app = Flask(__name__)

# 路由 简称API
@app.route('/')
# 视图  处理业务的
def index():

    '''
    items = []
    for i in range(1,9):
        data = {
            'id': i,
            'name':'张三' + str(i),
            'age':3,
            'gw':'爬虫',
            'xz':'18K'
        }
        items.append(data)

    context = {
        'data':items,
        'status':0
    }
        :return:
    '''
    # return '大家晚上好'
    # return render_template('index.html',data=context)
    return render_template('index.html')


# API  接口编写
@app.route('/api')
def index1():
    items = []
    for i in range(1,9):
        data = {
            'id': i,
            'name':'张三' + str(i),
            'age':3,
            'gw':'爬虫',
            'xz':'18K'
        }
        items.append(data)

    context = {
        'data':items,
        'status':0
    }

    return jsonify(data=context)

if __name__ == '__main__':
    app.run()






